package com.wkck.controller.frontend;

import com.wkck.VO.CompanyVo;
import com.wkck.VO.PageResult;
import com.wkck.dto.CompanyQueryParamsDto;
import com.wkck.result.Result;
import com.wkck.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: CK
 * @Date: 2024/02/28/13:02
 * @Description:
 */
@Api(value = "公司Api", tags = "公司api")
@Slf4j
@RestController
@RequestMapping("/user/company")
public class CompanyFrontendController {

    @Autowired
    private CompanyService companyService;

    @PostMapping("/list")
    @ApiOperation(value = "得到所有公司完整信息")
    public Result<PageResult> getAllCompanyInfo(@RequestBody CompanyQueryParamsDto companyQueryParamsDto) {
        log.info("查询所有公司信息 参数：{}", companyQueryParamsDto);
        return Result.success(companyService.getAllCompanyInfo(companyQueryParamsDto));
    }

    /**
    * @Author: CK
    * @Date: 2024/3/16
    * @Param: [company]
    * @Description: 根据公司名称获得公司信息
    */
    @GetMapping("/name")
    @ApiOperation(value = "根据公司名称获得公司信息")
    public Result<CompanyVo> getCompanyVo(String company) {
        log.info("需要获取公司信息的公司 =====> {}" , company);
        return Result.success(companyService.getCompanyVo(company));
    }
}
